package org.colcon.web.client.ui;

import org.colcon.web.client.Collective_Congress;
import org.colcon.web.model.framework.IItem;

import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;

public class ItemPanel extends ColConPanel 
{
	private IItem item;
	
	public ItemPanel(Collective_Congress client, IItem item)
	{
		super(client, "item");
		
		this.item = item;
		
		HorizontalPanel header = new HorizontalPanel();
		HorizontalPanel headerRight = new HorizontalPanel();
		
		header.setWidth("100%");
		headerRight.setWidth("100%");
		
		headerRight.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
		
		header.add(new LinkPanel(client, "link-title", item.getPath()));
		
		if(!item.isRoot())
			headerRight.add(new LinkPanel(client, "link-parent", item.getParentPath()));
		
		header.add(headerRight);
		add(header);
		
		if(item != null)
			add(new Label(item.getText()));
	}
	
	public IItem getItem()
	{
		return item;
	}
}
